package huadi.algorithm.sort;

/**
 * InsertionSort 插入排序
 *
 * @author Huadi
 */
public class InsertionSort {
    public static void sort(int[] array) {
        for (int i = 1; i < array.length; i++) {
            int key = array[i];
            int j;
            for (j = i; j > 0 && key < array[j - 1]; j--) {
                array[j] = array[j - 1];
            }
            array[j] = key;
        }

    }
}
